package main

import (
	"fmt"
)

type Student struct {
	Name string
	Age int
	School string
}

func main() {
	// 定义
	var s Student
	fmt.Println(s)

	// 赋值
	s.Name="张三"
	s.Age=18
	s.School="bilibli大学"
	fmt.Println(s)

	s.Age += 10
	fmt.Println(s)

	// 定义2
	var s2 Student = Student{}
	s2.Name="张三"
	s2.Age=18
	s2.School="bilibli大学"
	fmt.Println(s2)
	// 按顺序赋值
	var s3 Student = Student{"张三", 18, "bilibli大学"}
	fmt.Println(s3)

	// 定义3
	var s4 *Student = new(Student)
	(*s4).Name = "张三"
	(*s4).Age = 18
	s4.School="bilibli大学"	// 简化 (*4).School ==> s4.School
	fmt.Println(*s4)

	// 定义4 返回结构体的指针类型
	var s5 *Student = &Student{}
	s5.Name="张三"
	s5.Age=18
	s5.School="bilibli大学"
	fmt.Println(*s5)

	var s6 *Student = &Student{"张三", 18, "bilibli大学"}
	fmt.Println(*s6)

	var s7 *Student = &Student{
		Name: "张三", Age: 18, School: "bilibli大学",}
	fmt.Println(*s7)
}